home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / src / gdb-4.12 / include / coff / mips.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  8.8 KB  |  322 lines

  1. /* ECOFF support on MIPS machines.
  2.    coff/ecoff.h must be included before this file.  */
  3.  
  4. /********************** FILE HEADER **********************/
  5.  
  6. struct external_filehdr {
  7.   unsigned char f_magic[2];    /* magic number            */
  8.   unsigned char f_nscns[2];    /* number of sections        */
  9.   unsigned char f_timdat[4];    /* time & date stamp        */
  10.   unsigned char f_symptr[4];    /* file pointer to symtab    */
  11.   unsigned char f_nsyms[4];    /* number of symtab entries    */
  12.   unsigned char f_opthdr[2];    /* sizeof(optional hdr)        */
  13.   unsigned char f_flags[2];    /* flags            */
  14. };
  15.  
  16. /* Magic numbers are defined in coff/ecoff.h.  */
  17. #define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
  18.                   ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
  19.                   ((x).f_magic!=MIPS_MAGIC_BIG) && \
  20.                   ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \
  21.                   ((x).f_magic!=MIPS_MAGIC_BIG2) && \
  22.                   ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \
  23.                   ((x).f_magic!=MIPS_MAGIC_BIG3))
  24.  
  25. #define    FILHDR    struct external_filehdr
  26. #define    FILHSZ    20
  27.  
  28. /********************** AOUT "OPTIONAL HEADER" **********************/
  29.  
  30.  
  31. typedef struct external_aouthdr
  32. {
  33.   unsigned char magic[2];    /* type of file                */
  34.   unsigned char    vstamp[2];    /* version stamp            */
  35.   unsigned char    tsize[4];    /* text size in bytes, padded to FW bdry*/
  36.   unsigned char    dsize[4];    /* initialized data "  "        */
  37.   unsigned char    bsize[4];    /* uninitialized data "   "        */
  38.   unsigned char    entry[4];    /* entry pt.                */
  39.   unsigned char text_start[4];    /* base of text used for this file */
  40.   unsigned char data_start[4];    /* base of data used for this file */
  41.   unsigned char bss_start[4];    /* base of bss used for this file */
  42.   unsigned char gprmask[4];    /* ?? */
  43.   unsigned char cprmask[4][4];    /* ?? */
  44.   unsigned char gp_value[4];    /* value for gp register */
  45. } AOUTHDR;
  46.  
  47. /* compute size of a header */
  48.  
  49. #define AOUTSZ (sizeof(AOUTHDR))
  50.  
  51. /********************** SECTION HEADER **********************/
  52.  
  53. struct external_scnhdr {
  54.   unsigned char    s_name[8];    /* section name            */
  55.   unsigned char    s_paddr[4];    /* physical address, aliased s_nlib */
  56.   unsigned char    s_vaddr[4];    /* virtual address        */
  57.   unsigned char    s_size[4];    /* section size            */
  58.   unsigned char    s_scnptr[4];    /* file ptr to raw data for section */
  59.   unsigned char    s_relptr[4];    /* file ptr to relocation    */
  60.   unsigned char    s_lnnoptr[4];    /* file ptr to line numbers    */
  61.   unsigned char    s_nreloc[2];    /* number of relocation entries    */
  62.   unsigned char    s_nlnno[2];    /* number of line number entries*/
  63.   unsigned char    s_flags[4];    /* flags            */
  64. };
  65.  
  66. #define    SCNHDR    struct external_scnhdr
  67. #define    SCNHSZ    sizeof(SCNHDR)
  68.  
  69. /********************** RELOCATION DIRECTIVES **********************/
  70.  
  71. struct external_reloc {
  72.   unsigned char r_vaddr[4];
  73.   unsigned char r_bits[4];
  74. };
  75.  
  76. #define RELOC struct external_reloc
  77. #define RELSZ 8
  78.  
  79. /* MIPS ECOFF uses a packed 8 byte format for relocs.  These constants
  80.    are used to unpack the r_bits field.  */
  81.  
  82. #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG        16
  83. #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE    0
  84.  
  85. #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG        8
  86. #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE    8
  87.  
  88. #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG        0
  89. #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE    16
  90.  
  91. #define RELOC_BITS3_TYPE_BIG            0x1E
  92. #define RELOC_BITS3_TYPE_SH_BIG            1
  93. #define RELOC_BITS3_TYPE_LITTLE            0x78
  94. #define RELOC_BITS3_TYPE_SH_LITTLE        3
  95.  
  96. #define RELOC_BITS3_EXTERN_BIG            0x01
  97. #define RELOC_BITS3_EXTERN_LITTLE        0x80
  98.  
  99. /* The r_type field in a reloc is one of the following values.  I
  100.    don't know if any other values can appear.  These seem to be all
  101.    that occur in the Ultrix 4.2 libraries.  */
  102. #define MIPS_R_IGNORE    0
  103. #define MIPS_R_REFHALF    1
  104. #define MIPS_R_REFWORD    2
  105. #define MIPS_R_JMPADDR    3
  106. #define MIPS_R_REFHI    4
  107. #define MIPS_R_REFLO    5
  108. #define MIPS_R_GPREL    6
  109. #define MIPS_R_LITERAL    7
  110.  
  111. /********************** STABS **********************/
  112.  
  113. #define MIPS_IS_STAB ECOFF_IS_STAB
  114. #define MIPS_MARK_STAB ECOFF_MARK_STAB
  115. #define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB
  116.  
  117. #define DEFAULT_DATA_SECTION_ALIGNMENT 4
  118. #define DEFAULT_BSS_SECTION_ALIGNMENT 4
  119. #define DEFAULT_TEXT_SECTION_ALIGNMENT 16
  120. /* For new sections we havn't heard of before */
  121. #define DEFAULT_SECTION_ALIGNMENT 4
  122.  
  123. /********************** SYMBOLIC INFORMATION **********************/
  124.  
  125. /* Written by John Gilmore.  */
  126.  
  127. /* ECOFF uses COFF-like section structures, but its own symbol format.
  128.    This file defines the symbol format in fields whose size and alignment
  129.    will not vary on different host systems.  */
  130.  
  131. /* File header as a set of bytes */
  132.  
  133. struct hdr_ext {
  134.     unsigned char     h_magic[2];
  135.     unsigned char    h_vstamp[2];
  136.     unsigned char    h_ilineMax[4];
  137.     unsigned char    h_cbLine[4];
  138.     unsigned char    h_cbLineOffset[4];
  139.     unsigned char    h_idnMax[4];
  140.     unsigned char    h_cbDnOffset[4];
  141.     unsigned char    h_ipdMax[4];
  142.     unsigned char    h_cbPdOffset[4];
  143.     unsigned char    h_isymMax[4];
  144.     unsigned char    h_cbSymOffset[4];
  145.     unsigned char    h_ioptMax[4];
  146.     unsigned char    h_cbOptOffset[4];
  147.     unsigned char    h_iauxMax[4];
  148.     unsigned char    h_cbAuxOffset[4];
  149.     unsigned char    h_issMax[4];
  150.     unsigned char    h_cbSsOffset[4];
  151.     unsigned char    h_issExtMax[4];
  152.     unsigned char    h_cbSsExtOffset[4];
  153.     unsigned char    h_ifdMax[4];
  154.     unsigned char    h_cbFdOffset[4];
  155.     unsigned char    h_crfd[4];
  156.     unsigned char    h_cbRfdOffset[4];
  157.     unsigned char    h_iextMax[4];
  158.     unsigned char    h_cbExtOffset[4];
  159. };
  160.  
  161. /* File descriptor external record */
  162.  
  163. struct fdr_ext {
  164.     unsigned char    f_adr[4];
  165.     unsigned char    f_rss[4];
  166.     unsigned char    f_issBase[4];
  167.     unsigned char    f_cbSs[4];
  168.     unsigned char    f_isymBase[4];
  169.     unsigned char    f_csym[4];
  170.     unsigned char    f_ilineBase[4];
  171.     unsigned char    f_cline[4];
  172.     unsigned char    f_ioptBase[4];
  173.     unsigned char    f_copt[4];
  174.     unsigned char    f_ipdFirst[2];
  175.     unsigned char    f_cpd[2];
  176.     unsigned char    f_iauxBase[4];
  177.     unsigned char    f_caux[4];
  178.     unsigned char    f_rfdBase[4];
  179.     unsigned char    f_crfd[4];
  180.     unsigned char    f_bits1[1];
  181.     unsigned char    f_bits2[3];
  182.     unsigned char    f_cbLineOffset[4];
  183.     unsigned char    f_cbLine[4];
  184. };
  185.  
  186. #define    FDR_BITS1_LANG_BIG        0xF8
  187. #define    FDR_BITS1_LANG_SH_BIG        3
  188. #define    FDR_BITS1_LANG_LITTLE        0x1F
  189. #define    FDR_BITS1_LANG_SH_LITTLE    0
  190.  
  191. #define    FDR_BITS1_FMERGE_BIG        0x04
  192. #define    FDR_BITS1_FMERGE_LITTLE        0x20
  193.  
  194. #define    FDR_BITS1_FREADIN_BIG        0x02
  195. #define    FDR_BITS1_FREADIN_LITTLE    0x40
  196.  
  197. #define    FDR_BITS1_FBIGENDIAN_BIG    0x01
  198. #define    FDR_BITS1_FBIGENDIAN_LITTLE    0x80
  199.  
  200. #define    FDR_BITS2_GLEVEL_BIG        0xC0
  201. #define    FDR_BITS2_GLEVEL_SH_BIG        6
  202. #define    FDR_BITS2_GLEVEL_LITTLE        0x03
  203. #define    FDR_BITS2_GLEVEL_SH_LITTLE    0
  204.  
  205. /* We ignore the `reserved' field in bits2. */
  206.  
  207. /* Procedure descriptor external record */
  208.  
  209. struct pdr_ext {
  210.     unsigned char    p_adr[4];
  211.     unsigned char    p_isym[4];
  212.     unsigned char    p_iline[4];
  213.     unsigned char    p_regmask[4];
  214.     unsigned char    p_regoffset[4];
  215.     unsigned char    p_iopt[4];
  216.     unsigned char    p_fregmask[4];
  217.     unsigned char    p_fregoffset[4];
  218.     unsigned char    p_frameoffset[4];
  219.     unsigned char    p_framereg[2];
  220.     unsigned char    p_pcreg[2];
  221.     unsigned char    p_lnLow[4];
  222.     unsigned char    p_lnHigh[4];
  223.     unsigned char    p_cbLineOffset[4];
  224. };
  225.  
  226. /* Line numbers */
  227.  
  228. struct line_ext {
  229.     unsigned char    l_line[4];
  230. };
  231.  
  232. /* Symbol external record */
  233.  
  234. struct sym_ext {
  235.     unsigned char    s_iss[4];
  236.     unsigned char    s_value[4];
  237.     unsigned char    s_bits1[1];
  238.     unsigned char    s_bits2[1];
  239.     unsigned char    s_bits3[1];
  240.     unsigned char    s_bits4[1];
  241. };
  242.  
  243. #define    SYM_BITS1_ST_BIG        0xFC
  244. #define    SYM_BITS1_ST_SH_BIG        2
  245. #define    SYM_BITS1_ST_LITTLE        0x3F
  246. #define    SYM_BITS1_ST_SH_LITTLE        0
  247.  
  248. #define    SYM_BITS1_SC_BIG        0x03
  249. #define    SYM_BITS1_SC_SH_LEFT_BIG    3
  250. #define    SYM_BITS1_SC_LITTLE        0xC0
  251. #define    SYM_BITS1_SC_SH_LITTLE        6
  252.  
  253. #define    SYM_BITS2_SC_BIG        0xE0
  254. #define    SYM_BITS2_SC_SH_BIG        5
  255. #define    SYM_BITS2_SC_LITTLE        0x07
  256. #define    SYM_BITS2_SC_SH_LEFT_LITTLE    2
  257.  
  258. #define    SYM_BITS2_RESERVED_BIG        0x10
  259. #define    SYM_BITS2_RESERVED_LITTLE    0x08
  260.  
  261. #define    SYM_BITS2_INDEX_BIG        0x0F
  262. #define    SYM_BITS2_INDEX_SH_LEFT_BIG    16
  263. #define    SYM_BITS2_INDEX_LITTLE        0xF0
  264. #define    SYM_BITS2_INDEX_SH_LITTLE    4
  265.  
  266. #define    SYM_BITS3_INDEX_SH_LEFT_BIG    8
  267. #define    SYM_BITS3_INDEX_SH_LEFT_LITTLE    4
  268.  
  269. #define    SYM_BITS4_INDEX_SH_LEFT_BIG    0
  270. #define    SYM_BITS4_INDEX_SH_LEFT_LITTLE    12
  271.  
  272. /* External symbol external record */
  273.  
  274. struct ext_ext {
  275.     unsigned char    es_bits1[1];
  276.     unsigned char    es_bits2[1];
  277.     unsigned char    es_ifd[2];
  278.     struct    sym_ext es_asym;
  279. };
  280.  
  281. #define    EXT_BITS1_JMPTBL_BIG        0x80
  282. #define    EXT_BITS1_JMPTBL_LITTLE        0x01
  283.  
  284. #define    EXT_BITS1_COBOL_MAIN_BIG    0x40
  285. #define    EXT_BITS1_COBOL_MAIN_LITTLE    0x02
  286.  
  287. #define    EXT_BITS1_WEAKEXT_BIG        0x20
  288. #define    EXT_BITS1_WEAKEXT_LITTLE    0x04
  289.  
  290. /* Dense numbers external record */
  291.  
  292. struct dnr_ext {
  293.     unsigned char    d_rfd[4];
  294.     unsigned char    d_index[4];
  295. };
  296.  
  297. /* Relative file descriptor */
  298.  
  299. struct rfd_ext {
  300.   unsigned char    rfd[4];
  301. };
  302.  
  303. /* Optimizer symbol external record */
  304.  
  305. struct opt_ext {
  306.   unsigned char o_bits1[1];
  307.   unsigned char o_bits2[1];
  308.   unsigned char o_bits3[1];
  309.   unsigned char o_bits4[1];
  310.   struct rndx_ext o_rndx;
  311.   unsigned char o_offset[4];
  312. };
  313.  
  314. #define OPT_BITS2_VALUE_SH_LEFT_BIG    16
  315. #define OPT_BITS2_VALUE_SH_LEFT_LITTLE    0
  316.  
  317. #define OPT_BITS3_VALUE_SH_LEFT_BIG    8
  318. #define OPT_BITS3_VALUE_SH_LEFT_LITTLE    8
  319.  
  320. #define OPT_BITS4_VALUE_SH_LEFT_BIG    0
  321. #define OPT_BITS4_VALUE_SH_LEFT_LITTLE    16
  322.